#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define MAX_N 100000


int nums[MAX_N + 5];
long long pre[MAX_N + 5];
int n;
long long k;

bool ispass(int left, int right)
{
    int mid = (right - left) / 2 + left;
    long long need = (pre[right + 1] - pre[mid + 1]) - (pre[mid] - pre[left]) - 
        (right - mid - (mid - left)) * nums[mid];
    if(abs(need) <= k) return true;
    return false;
}



bool isreasonable(int length)
{
    int ans = pre[length];
    for(int left = 0, right = left + length - 1; right < n; left++, right++)
    {
        if(ispass(left, right) == true) return true;
        ans -= nums[left];
        ans += nums[right + 1];
    }
    return false;
}


int32_t calculate()
{
    int left = 0, right = n;
    while (left < right)
    {
        int mid = (right - left + 1) / 2  + left;
        fflush(stdout);
        if (isreasonable(mid))
        {
            left = mid;
        }
        else
        {
            right = mid - 1;
        }
    }
    return left;
}





int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> nums[i];
    }
    sort(nums, nums + n);
    for(int i = 0; i < n; i++)
    {
        pre[i + 1] = nums[i] +  pre[i];
    }
    cout << calculate();
    return 0;
}